<template>
  <div class="container-content">
    <el-form
      ref="formRef"
      :model="formObject"
      label-width="100px"
      label-position="left"
    >
      <el-card shadow="never">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="文件名称">
              <el-input v-model="formObject.fileName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="新增时间">
              <el-date-picker
                v-model="formObject.createTime"
                type="date"
                placeholder="选择日期"
                style="width: 100%"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="申请时间">
              <el-date-picker
                v-model="formObject.applyTime"
                type="date"
                placeholder="选择日期"
                style="width: 100%"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="份数">
              <el-input v-model="formObject.number"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="申请事由">
              <el-input v-model="formObject.reason"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="印章类型">
              <el-input v-model="formObject.sealTypeName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="印章Id">
              <el-input v-model="formObject.sealId"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="使用类型">
              <el-radio v-model="formObject.useType" :label="1" border
                >文件</el-radio
              >
              <el-radio v-model="formObject.useType" :label="2" border
                >异地使用</el-radio
              >
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>
  </div>
</template>
<script>
import {
  addSealContract,
  editSealList,
  getDetailSeal,
} from "@/api/system/contract";
export default {
  props: ["id"],
  data() {
    return {
      formObject: {
        applyTime: "",
        createTime: "",
        fileName: "",
        id: "",

        limit: 0,
        number: null,
        page: 0,
        reason: "",
        sealId: "",
        sealTypeName: "",
        token: "",
        useType: null,
        userId: "",
      },
    };
  },
  methods: {
    onSubmit() {
      if (this.id) {
        editSealList(this.formObject).then((res) => {
          if (res.code === 200) {
            this.$message({
              message: "修改成功！",
              type: "success",
            });
          }
        });
      } else {
        addSealContract(this.formObject).then((res) => {
          if (res.code === 200) {
            this.$message({
              message: "新增成功！",
              type: "success",
            });
          }
        });
      }
    },
    getData(id) {
      getDetailSeal(id).then((res) => {
        this.formObject = res.data;
      });
    },
  },
  created() {
    if (this.id) {
      this.getData(this.id);
    }
  },
};
</script>
<style lang="scss" scoped></style>
